package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.query.album.AlbumInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumListVo;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AlbumInfoMapper extends BaseMapper<AlbumInfo> {

    AlbumInfo getAlbumInfoById(Integer id);

    IPage<AlbumListVo> findUserAlbumPage(Page<AlbumListVo> page1, @Param("query") AlbumInfoQuery albumInfoQuery);

    AlbumStatVo getAlbumStatVo(Long albumId);

    @Update("""
            update album_stat
            set stat_num = stat_num + #{count}
            where album_id = #{albumId} and stat_type = #{statType}
            """)
    void updateStat(@Param( "albumId")Long albumId, @Param("statType") String statType, @Param("count")Integer count);
}
